package com.example.demo.controller;

import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/user")
public class UserController {

    @RequestMapping("/login")
    public String login(String username, String password) {
        //非空校验
        if (!StringUtils.hasLength(username) || !StringUtils.hasLength(password)) {
            return "用户名或密码不能为空!";
        }
        if (username.equals("zn") && password.equals("123")) {
            return "登录成功";
        }
        return "很遗憾，登陆失败！原因：用户名或密码错误!";
    }

}
